package cn.com.dpc.setActivity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import cn.com.dpc.R;

public class AlarmLevelSetActivity extends Activity {
	private List<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
	private ListView set01;
	private String lv_items[] = { "紧急", "重要", "一般" };

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.alarmsoundset);

		set01 = (ListView) findViewById(R.id.set01);

		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("name", "Android");
		listItem.add(map);

		SimpleAdapter sa = new SimpleAdapter(AlarmLevelSetActivity.this,
				listItem, R.layout.listview, new String[] { "name", },
				new int[] { R.id.itemTitle });
		// set01.setAdapter(sa);

		set01.setAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_multiple_choice, lv_items));
		set01.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

		set01.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView arg0, View arg1, int arg2,
					long arg3) {
				List list = new ArrayList();
				SparseBooleanArray a = set01.getCheckedItemPositions();
				for (int i = 0; i < lv_items.length; i++) {
					if (a.valueAt(i)) {
						Long val = set01.getAdapter().getItemId(a.keyAt(i));
						Log.v("AAAAAAAAA", "index=" + val.toString());
						list.add(set01.getAdapter().getItemId((a.keyAt(i))));
					}
				}
			}
		}); // End of Listener

		// 隐藏按钮
		ImageButton editButton = (ImageButton) findViewById(R.id.edit_button);
		editButton.setVisibility(View.INVISIBLE);
		ImageButton backButton = (ImageButton) findViewById(R.id.back_button);
		backButton.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				AlarmLevelSetActivity.this.finish();
			}
		});
		TextView titleText = (TextView) findViewById(R.id.myTitle);
		titleText.setText("告警等级设置");
	}
}
